package com.ruoyi.contract.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.ruoyi.contract.domain.ConBusinessType;
import com.ruoyi.contract.mapper.ConBusinessTypeMapper;
import com.ruoyi.contract.service.IConBusinessTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by zhangxiang on 2021/10/9.
 */
@Service
public class ConBusinessTypeServiceimpl extends ServiceImpl<ConBusinessTypeMapper, ConBusinessType> implements IConBusinessTypeService {

    @Autowired
    ConBusinessTypeMapper conBusinessTypeMapper;

    @Override
    public List<String> getBusTypeByConId(Long conId) {
        List<String> conBusinessTypeList = conBusinessTypeMapper.getConBusTypeByConId(conId);
        return conBusinessTypeList;
    }

    @Override
    public boolean cloneConBusinessType(Long oldConId, Long newConId) {
        List<ConBusinessType> conBusinessTypeList = conBusinessTypeMapper.selectList(new QueryWrapper<ConBusinessType>().lambda().eq(ConBusinessType::getConId,oldConId));
        for(ConBusinessType conBusinessType : conBusinessTypeList){
            conBusinessType.setConId(newConId);
            this.save(conBusinessType);
        }
        return true;
    }
}
